#!/usr/bin/env python
# encoding: utf-8
"""
@version :
@author  :
@license :
@contact : ****@massclouds.com
@site    : http://blog.csdn.net/***
@software: PyCharm
@time    : 17-2-13 上午10:33
"""
# KVMGT_template_xml_str
KVMGT_TEMPLATE_XML_STR =  "<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'> \
  <name>{name}</name> \
  <memory unit='MiB'>{memory}</memory> \
  <currentMemory unit='MiB'>{memory}</currentMemory> \
  <vcpu placement='static'>{vcpu}</vcpu> \
  <os> \
    <type arch='x86_64' machine='pc'>hvm</type> \
    <boot dev='hd'/> \
    <boot dev='cdrom'/> \
  </os> \
  <features> \
    <acpi/> \
    <apic/> \
    <pae/> \
  </features> \
  <cpu mode='host-passthrough'> \
    <topology sockets='1' cores='{vcpu}' threads='1'/> \
  </cpu> \
  <clock offset='localtime'> \
    <timer name='rtc' tickpolicy='catchup'/> \
  </clock> \
  <on_poweroff>destroy</on_poweroff> \
  <on_reboot>restart</on_reboot> \
  <on_crash>restart</on_crash> \
  <devices> \
    <emulator>/usr/bin/qemu-system-x86_64</emulator> \
    <controller type='usb' index='0' model='ich9-ehci1'> \
    </controller> \
    <controller type='usb' index='0' model='ich9-uhci1'> \
      <master startport='0'/> \
    </controller> \
    <controller type='usb' index='0' model='ich9-uhci2'> \
      <master startport='2'/> \
    </controller> \
    <controller type='usb' index='0' model='ich9-uhci3'> \
      <master startport='4'/> \
    </controller> \
    <controller type='pci' index='0' model='pci-root'/> \
    <controller type='virtio-serial' index='0'> \
    </controller> \
    <controller type='ide' index='0'> \
    </controller> \
    <redirdev bus='usb' type='spicevmc'> \
    </redirdev> \
    <redirdev bus='usb' type='spicevmc'> \
    </redirdev> \
    <redirdev bus='usb' type='spicevmc'> \
    </redirdev> \
    <redirdev bus='usb' type='spicevmc'> \
    </redirdev> \
    <interface type='bridge'> \
      <source bridge='br0'/> \
      <model type='virtio'/> \
    </interface> \
    <graphics type='spice' port='-1' autoport='yes' listen='0.0.0.0'> \
      <listen type='address' address='0.0.0.0'/> \
    </graphics> \
    <serial type='pty'> \
      <target port='0'/> \
    </serial> \
    <console type='pty'> \
      <target type='serial' port='0'/> \
    </console> \
    <input type='mouse' bus='ps2'/> \
    <input type='keyboard' bus='ps2'/> \
    <sound model='ich6'> \
    </sound> \
    <video> \
      <model type='cirrus' vram='9216' heads='1'/> \
    </video> \
    <memballoon model='virtio'> \
    </memballoon> \
  </devices> \
  <qemu:commandline> \
    <qemu:arg value='-vgt'/> \
    <qemu:arg value='-vga'/> \
    <qemu:arg value='vgt'/> \
    <qemu:arg value='-vgt_low_gm_sz'/> \
    <qemu:arg value='128'/> \
    <qemu:arg value='-vgt_high_gm_sz'/> \
    <qemu:arg value='384'/> \
    <qemu:arg value='-vgt_fence_sz'/> \
    <qemu:arg value='4'/> \
    <qemu:arg value='-no-hpet'/> \
  </qemu:commandline> \
</domain> \
"

if __name__ == '__main__':
    print KVMGT_TEMPLATE_XML_STR

